﻿<Window x:Class="Plethora.Context.Wpf.Example.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        xmlns:context="clr-namespace:Plethora.Context.Wpf;assembly=Plethora.Context.Wpf"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value ="5,0,5,0" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Margin" Value ="5" />
        </Style>


        <context:WpfContextSourceTemplate x:Key="textboxContext" Name="Textbox" Rank="-5" Data="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>

        <context:WpfContextSourceTemplateCollection x:Key="contractContext">
            <context:WpfContextSourceTemplate Name="Contract" Data="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}"/>
            <context:WpfContextSourceTemplate Name="SignedContract" Data="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}"/>
            <StaticResource ResourceKey="textboxContext" />
        </context:WpfContextSourceTemplateCollection>

        <context:ActionsPrecedenceAdapter x:Key="itemsPrecedenceAdapter">
            <context:ActionsPrecedenceAdapter.PrecedenceLists>
                <x:Array Type="system:String">
                    <system:String>Edit Contract</system:String>
                    <system:String>View Signed Contract</system:String>
                    <system:String>View Contract</system:String>
                </x:Array>
                <x:Array Type="system:String">
                    <system:String>Paste</system:String>
                    <system:String>Copy</system:String>
                    <system:String>Cut</system:String>
                </x:Array>
            </context:ActionsPrecedenceAdapter.PrecedenceLists>
        </context:ActionsPrecedenceAdapter>
        
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="280*"/>
            <ColumnDefinition Width="220*"/>
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="0" >
            <DockPanel>
                <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">Contract:</TextBlock>
                <TextBox context:WpfContext.ContextSourceTemplate="{StaticResource contractContext}">
                    1234

                    <TextBox.ContextMenu>
                        <ContextMenu>
                            <context:WpfContextMenuItem DisableGrouping="True" ActionsAdapter="{StaticResource itemsPrecedenceAdapter}" />
                        </ContextMenu>
                    </TextBox.ContextMenu>
                </TextBox>
            </DockPanel>
            <DockPanel>
                <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">Instrument:</TextBlock>
                <TextBox >
                    VOD.L

                    <TextBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Alpha" />
                            <context:WpfContextMenuItem />
                            <MenuItem Header="Omega" />
                        </ContextMenu>
                    </TextBox.ContextMenu>
                    <context:WpfContext.ContextSourceTemplate>
                        <context:WpfContextSourceTemplateCollection>
                            <StaticResource ResourceKey="textboxContext" />
                            <context:WpfContextSourceTemplate Name="Instrument" Data="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"/>
                        </context:WpfContextSourceTemplateCollection>
                    </context:WpfContext.ContextSourceTemplate>
                </TextBox>
            </DockPanel>

            <TextBox Name="ContextTextBox" context:WpfContext.IsActivityItem="True" />
        </StackPanel>

        <StackPanel Grid.Column="1" Name="ContextActionStack" context:WpfContext.IsActivityItem="True" />
    </Grid>
</Window>
